package com.mystnihon.interceptors;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AllowAccessInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 1L;

	
	public void init(){
		System.out.println("dans la méthode init.......");
	}
	
	public String intercept(ActionInvocation actionInvocator) throws Exception {

		
		System.out.println("dans la méthode intercept.......");
		
		Map<String, Object> session = actionInvocator.getInvocationContext().getSession();
		
		if(session.get("allowAccess")==null)
		{
			return "allowAccess";
		}else
			{
				if (!session.isEmpty())
				{
					return actionInvocator.invoke();
				}
				else
				{
					return "allowAccess";
				}
			}
	}

}
